package plus.stmt;

import plus.B;
import plus.exp.Exp;
import plus.run.Emit;
import plus.run.Label;
import plus.run.VM;

public class P_Repeat extends Loop {
	final Statement stmt;
	final Exp condition;

	public P_Repeat(String label, Statement stmt, Exp condition) {
		super(label);
		this.condition = condition;
		this.stmt = stmt;
	}
	@Override
	public void threadScope() {
		enter();
		stmt.threadScope();
		condition.threadScope();
		condition.unify_with(B._bool);
		exit();
	}
	@Override
	public
	void compile() {
		Emit.asm(VM.TRU);
		Label body = new Label();
		body.post();
		Emit.pop();
		again.post();
		stmt.compile();
		condition.compileJcc(body, false);
		Emit.pop();
		after.post();
	}
}
